//
//  WebSocketRocketManger.h
//  IMDome
//
//  Created by limaohuyu on 2020/8/13.
//  Copyright © 2020 czw. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <SocketRocket.h>

NS_ASSUME_NONNULL_BEGIN


#pragma mark - WebSocketRocketManger
@protocol WebSocketRocketMangerDelegate <NSObject>
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message;
@optional
- (void)webSocketDidOpen:(SRWebSocket *)webSocket;
@end

@interface WebSocketRocketManger : NSObject

@property(nonatomic,copy)NSString * senderId ;
+ (WebSocketRocketManger *)instance;

//delegate
@property(nonatomic,weak) id<WebSocketRocketMangerDelegate> delegate;

/// 链接WebSocket
/// @param urlString  ws://
-(void)openWebSocketWithURLString:(NSString *)urlString;

/// 发送消息
/// @param message 消息
- (void)sendMessage:(id)message;

/// 主动关闭链接
-(void)closeWebSocket;
/// Block
@property (nonatomic,copy) void(^webSocketDidOpen)(void) ;

@property (nonatomic,copy) void(^didReceiveMessage)(id message)  ;

@property (nonatomic,copy) void(^closeWebSocketBlocl)(void);


@end

NS_ASSUME_NONNULL_END
